home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / engine.arc / DELBAK.PAS < prev    next >
Pascal/Delphi Source File  |  1989-03-29  |  1KB  |  45 lines

  1. {$R-,S+,I+,D+,F-,V-,B-,N-,L+ }
  2. {$M $4000,0,0}
  3. PROGRAM DelBak;
  4.  
  5.   (********************************************************)
  6.   (* Uses SearchEngine to find and delete all *.BAK files *)
  7.   (* in any subdirectory in the current volume.           *)
  8.   (********************************************************)
  9.  
  10. USES DOS,Engine;
  11.  
  12. VAR
  13.   path    : PathStr;
  14.   ErrCode : Byte;
  15.   Number  : Integer;
  16.   Size    : LongInt;
  17.  
  18.   {$F+} PROCEDURE DelFile(VAR S : SearchRec; path : PathStr); {$F-}
  19.   VAR F : FILE;
  20.   BEGIN
  21.     Inc(Size, S.Size);
  22.     Assign(F, path + S.name);
  23.     Erase(F);
  24.     Inc(Number);
  25.   END;
  26.  
  27.   PROCEDURE Initialize;
  28.   BEGIN
  29.     Number := 0;
  30.     Size := 0;
  31.     GetDir(0, path);
  32.     IF Length(path) = 2 THEN path := path + '\'
  33.     ELSE path[0] := #3;
  34.     WriteLn('Going to delete ALL *.BAK files in the current volume.');
  35.     WriteLn('Press <Return> to proceed, ^Break to stop.');
  36.     ReadLn;
  37.   END;
  38.  
  39.   BEGIN
  40.     Initialize;
  41.     SearchEngineAll(path, '*.bak', AnyFile, DelFile, ErrCode);
  42.     WriteLn
  43.     ('Erased ',Number,' *.BAK files for a saving of ',Size,' bytes');
  44.   END.
  45.